#include "Thread.hpp"
#include <stdio.h>
#include<memory>
#include<unordered_map>
#include<vector>
#define NUM 10
using namespace ThreadModule;

using Thread_ptr_t = std::shared_ptr<Thread>;

int main()
{

    std::unordered_map<std::string,Thread_ptr_t> threads;
    for(int i = 0;i<NUM;i++)
    {
        Thread_ptr_t t = std::make_shared<Thread>([](std::string name){
            while(true)
            {
                std::cout<<"我是子进程，我的名字是："<<name<<std::endl;
                break;
            }

        });
        threads[t->Name()] = t;
    }

    std::cout<<"开始运行啦！"<<std::endl;

    for(auto thread:threads)
    {
        thread.second->Start();
    }

    sleep(2);

    std::cout<<"开始回收啦！"<<std::endl;

    for(auto thread:threads)
    {
        thread.second->Join();
    }
    sleep(1);
    return 0;
}